package com.company;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.Socket;
import java.nio.charset.StandardCharsets;

public class Test02 {
    //尝试独立写出客户端开发代码
    public static void main(String[] args) throws IOException {
        String content = new String("嗨嗨嗨");
        Socket socket = new Socket("192.168.1.105", 9832);
        OutputStream outputStream = socket.getOutputStream();
        outputStream.write(content.getBytes());//直到此处可以完整记忆
        socket.shutdownOutput();

        InputStream inputStream = socket.getInputStream();
        int len;
        byte[] buf = new byte[1024];
        while ((len = inputStream.read(buf))!=-1) {
            System.out.println(new String(buf,0,len));
        }
        socket.close();

        outputStream.close();

    }
}
